home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / lang / c--c0202 / dos.h-- < prev    next >
Encoding:
Text File  |  1994-04-21  |  5.3 KB  |  313 lines

  1. /*
  2.     SPHINX Programming (C) 1994.
  3.     NAME:  DOS.H--
  4.     DESCRIPTION:  This file defines several DOS related procedures and
  5.                   functions.
  6.     LAST MODIFIED:  21 Apr 1994
  7.     PROCEDURES DEFINED IN THIS FILE:
  8.         : void ABORT()
  9.         : void ALLOCBESTFIT()
  10.         : void ALLOCFIRSTFIT()
  11.         : void ALLOCLASTFIT()
  12.         : word ALLOCSTRATEGY()
  13.         : byte DOSGETDATE()
  14.         : void DOSGETTIME()
  15.         : byte DOSsetdate(byte day,byte month,year)
  16.         : byte DOSsettime(byte hour,byte minute,byte second)
  17.         : void DOSWRITESTR(stringoffset)
  18.         : void ENVSTR(environ_string)
  19.         : void EXIT(byte returnvalue)
  20.         : byte GETBOOTDRIVE()
  21.         : byte GETCH()
  22.         : byte GETCHE()
  23.         : word GETDTA()
  24.         : void setDTA(DTAsegment,DTAoffset)
  25.         : word spawn(filename,commandline,environment)
  26. */
  27.  
  28.  
  29. // default offset address of Disk Transfer Area:
  30.  
  31. ?define  DTA_ADDRESS  0x80
  32.  
  33.  
  34. // Procedure Definitions:
  35.  
  36.  
  37. : void ABORT ()
  38. {
  39. ?DOSrequired 0x0100
  40. $INT 0x20
  41. }
  42.  
  43.  
  44. : void ENVSTR ()  /* AX = offset of string of environment variable name */
  45.                   /* DS must equal the segment address of the PSP, in other
  46.                      words, the same value it had when the program started
  47.                      executing, this should be the same as CS. 
  48.                   */
  49. /*
  50.     attempts to retrive an environmental variable 
  51. */
  52. {BX = AX;
  53. ES = DSWORD[0x2C];
  54. DI = 0;
  55. TOP: SI = BX;
  56. $ CMP ESBYTE[DI],0
  57. $ JE FINISHED
  58. CX = 100;
  59. $ REPZ
  60. $ CMPSB
  61. SI--;
  62. $ CMP DSBYTE[SI],0
  63. $ JNE HERE
  64. $ CMP ESBYTE[DI-1],'='
  65. $ JE PREFINISHED
  66. HERE: DI++;
  67. $ CMP ESBYTE[DI],0
  68. $ JNE HERE
  69. DI++;
  70. $ JMP TOP
  71. PREFINISHED:
  72. // DI++;
  73. FINISHED:
  74. }
  75. /*  RETURNS:   AX,BX,CX,SI = undefined
  76.                ES:DI = environment string
  77. */
  78.  
  79.  
  80.  
  81. : word spawn (word filenameaddress,commandlineaddress,environmentaddress)
  82. {$ PUSH CS
  83. AX = 0x6C;
  84. $ PUSH AX
  85. $ PUSH CS
  86. AX = 0x5C;
  87. $ PUSH AX
  88. $ PUSH DS
  89. $ PUSH commandlineaddress
  90. $ PUSH environmentaddress
  91. ES = SS;
  92. BX = SP;
  93. DX = filenameaddress;
  94. AX = 0x4B00;
  95. $ INT 0x21
  96. ?DOSrequired 0x0300
  97. IF( NOTCARRYFLAG )
  98.     $ XOR AX,AX
  99. SP += 14;
  100. }
  101. /*  RETURNS:  BX,DX,ES = undefined
  102.               If successful:
  103.                   AX = 0
  104.               If unsuccessful:
  105.                   AX = error code 
  106. */
  107.  
  108.  
  109. : void ALLOCBESTFIT ()
  110. {
  111. ?DOSrequired 0x300
  112. AX = 0x5801;
  113. BX = 1;
  114. $ INT 0x21
  115. }
  116.  
  117.  
  118. : void ALLOCFIRSTFIT ()
  119. {
  120. ?DOSrequired 0x300
  121. AX = 0x5801;
  122. BX = 0;
  123. $ INT 0x21
  124. }
  125.  
  126.  
  127. : void ALLOCLASTFIT ()
  128. {
  129. ?DOSrequired 0x300
  130. AX = 0x5801;
  131. BX = 2;
  132. $ INT 0x21
  133. }
  134.  
  135.  
  136. : word ALLOCSTRATEGY ()
  137. {
  138. ?DOSrequired 0x300
  139. AX = 0x5800;
  140. $ INT 0x21
  141. IF( CARRYFLAG )
  142.     AX = -1;
  143. }
  144.  
  145.  
  146. : void EXIT ()  /* AL = value to return */
  147. {
  148. AH = 0x4C;
  149. $ INT 0x21
  150. }
  151.  
  152.  
  153. : word GETDTA ()
  154. /*
  155. GET DISK TRANSFER AREA ADDRESS
  156. Returns:  ES:BX -> address DTA
  157.           AH = 2Fh
  158. */
  159. {
  160. ?DOSrequired 0x200
  161. AH = 0x2F;
  162. $INT 0x21
  163. }
  164.  
  165.  
  166. : word setDTA (word DTAsegment, DTAoffset)
  167. /*
  168. SET DISK TRANSFER AREA ADDRESS
  169. Returns:  DX = DTAoffset
  170.           AH = 1Ah
  171. */
  172. {
  173. ?DOSrequired 0x100  // I think...
  174. DX = DTAoffset; 
  175. $PUSH DS
  176. DS = DTAsegment;
  177. AH = 0x1A;
  178. $INT 0x21
  179. $POP DS
  180. }
  181.  
  182.  
  183. : void DOSWRITESTR ()  /*  AX = address of string to write */
  184. /*
  185. Prints a string to the screen using a DOS interrupt.
  186. Returns:  DX = address of string to write
  187.           AH = 0x9
  188. */
  189. {
  190. ?DOSrequired 0x100
  191. DX = AX;
  192. AH = 0x9;
  193. $INT 0x21
  194. }
  195.  
  196.  
  197. : void DOSGETTIME ()
  198. /*
  199. Gets the current system time from DOS.
  200. Returns:  CH = hours
  201.           CL = minutes
  202.           DH = seconds
  203.           DL = hundredths of seconds (updated approx every 5/100 second)
  204.           AH = 0x2C
  205. */
  206. {
  207. ?DOSrequired 0x100
  208. AH = 0x2C;
  209. $INT 0x21
  210. }
  211.  
  212.  
  213. : byte DOSsettime (byte hour,minute,second)
  214. /*
  215. Sets the DOS system time.
  216. Returns:  AL = 0 if no error, else 0xFF if bad time value given
  217.           CH = hours
  218.           CL = minutes
  219.           DH = seconds
  220.           DL = 0
  221.           AH = 0x2D
  222. */
  223. {
  224. ?DOSrequired 0x100
  225. CH = hour;
  226. CL = minute;
  227. DH = second;
  228. DL = 0;  // hundredths of seconds
  229. AH = 0x2D;
  230. $INT 0x21
  231. }
  232.  
  233.  
  234. : byte GETBOOTDRIVE ()
  235. /*
  236. Gets the drive letter of the boot drive.
  237. Returns:  AL = boot drive (1=A:,2=B:,...)
  238.           AH = 0x33;
  239.           DL = AL
  240. */
  241. {
  242. ?DOSrequired 0x400
  243. AX = 0x3305;
  244. $INT 0x21
  245. AL = DL;
  246. }
  247.  
  248.  
  249.  
  250. : byte DOSGETDATE ()
  251. /*
  252. Gets the current system date from DOS.
  253. Returns:  DL = day
  254.           DH = month
  255.           CX = year
  256.           AL = day of the week (0=Sunday, 1=Monday, ...)
  257.           AH = 0x2A
  258. */
  259. {
  260. ?DOSrequired 0x100
  261. AH = 0x2A;
  262. $INT 0x21
  263. }
  264.  
  265.  
  266. : byte DOSsetdate (byte day,month; word year)
  267. /*
  268. Sets the DOS system date.
  269. Returns:  AL = 0 if no error, else 0xFF if bad date value given
  270.           DL = day
  271.           DH = month
  272.           CX = year
  273.           CH = hours
  274.           AH = 0x2B
  275. */
  276. {
  277. ?DOSrequired 0x100
  278. DL = day;
  279. DH = month;
  280. CX = year;
  281. AH = 0x2B;
  282. $INT 0x21
  283. }
  284.  
  285.  
  286. : byte GETCH ()
  287. /*
  288. Reads a key from the keyboard via DOS interrupt.  The key is not echoed to
  289. the screen.
  290. Returns:  AL = key code read
  291.           AH = 0x8;
  292. */
  293. {
  294. ?DOSrequired 0x100
  295. AH = 0x8;
  296. $INT 0x21
  297. }
  298.  
  299. : byte GETCHE ()
  300. /*
  301. Reads a key from the keyboard via DOS interrupt.  The key is echoed to the
  302. screen.
  303. Returns:  AL = key code read
  304.           AH = 0x8;
  305. */
  306. {
  307. ?DOSrequired 0x100
  308. AH = 0x1;
  309. $INT 0x21
  310. }
  311.  
  312.  
  313. /* end of DOS.H-- */